package org.knight.gearbox.concurrent.lock;

import java.util.concurrent.TimeUnit;

public interface Lock {


    /**
     *  a method try to acquire current lock and
     *  if can't acquire lock would return false immediately
     * @return
     */
    boolean tryLock();

    /**
     * a blocking method would wait until acquire current lock
     */
    void lock();



    /**
     * a method try to acquire current lock
     * if can't acquire lock would block until reached specified time
     * then return false
     * @param timeOut
     * @param timeUnit
     * @return
     */
    boolean  tryLock(Long timeOut, TimeUnit timeUnit);

    /**
     * return current ownned lock
     */
    void unlock();
}
